<template>
  <div
    class="container"
    :style="pageType == 4 ? 'background: #E4943C;' : 'background: #ffffff;'"
  >
    <div
      class="container_page"
      v-show="pageType == 4"
      style="margin: 0 0 84px 0; width: calc(100% - 16px)"
    >
      <div class="login_lang">
        <div class="login_lang_div" @click="showLang">
          <span>{{ $t(getCurrentLang.label) }}</span>
          <img src="@/assets/img/login/home_ic_down@2x.png" alt="" />
        </div>
      </div>
      <img src="@/assets/img/login/pic@2x.png" alt="" />
      <div class="Low_battery">
        {{ $t('Low_on_battery') }}
      </div>
      <div class="get_started">
        <div class="get_started_div" @click="startedLogin">
          {{ $t('Get_started') }}
        </div>
      </div>
    </div>
    <page-header
      :title="''"
      @click="pageType = 1"
      setClick
      v-if="pageType == 3"
    >
    </page-header>
    <div class="container_page" v-show="pageType == 1" style="margin: 44px 0">
      <div style="text-align: center">
        <img
          src="@/assets/img/login/logo.png"
          alt=""
          style="width: 88px; height: 88px"
        />
      </div>
      <div class="login_top" style="padding: 8px 0 28px 0">
        {{ $t('login_welcomeTitle') }}
      </div>

      <div class="login_btn" @click="loginBtn(0)">
        <img src="@/assets/img/login/phone@2x.png" alt="" />
        <span>{{
          $t('login_loginWith').replace('xx', $t('Login_phone'))
        }}</span>
        <div class="login_sign" v-show="loginWay === '0'">
          <span>{{ $t('login_recent') }}</span>
          <img src="@/assets/img/login/ic_extrusion@2x.png" alt="" />
        </div>
      </div>
      <!-- 邮箱登录已隐藏 -->
      <!-- <div class="login_btn" style="margin-top: 14px" @click="loginBtn(6)">
        <img src="@/assets/img/login/ic_email@2x.png" alt="" />
        <span>{{
          $t('login_loginWith').replace('xx', $t('login_email'))
        }}</span>
        <div class="login_sign" v-show="loginWay === '6'">
          <span>{{ $t('login_recent') }}</span>
          <img src="@/assets/img/login/ic_extrusion@2x.png" alt="" />
        </div>
      </div> -->
      <!-- <van-divider
        :style="{
          color: '#D2D8E2',
          borderColor: '#f5f5f7',
          padding: '0',
          fontSize: '20px',
          lineHeight: '24px',
          height: '36px'
        }"
      >
        {{ $t('login_or') }}
      </van-divider>
      <div class="login_btn" @click="loginBtn(2)">
        <img src="@/assets/img/login/google@2x.png" alt="" />
        <span>{{
          $t('login_loginWith').replace('xx', $t('Login_google'))
        }}</span>
        <div class="login_sign" v-show="loginWay === '2'">
          <span>{{ $t('login_recent') }}</span>
          <img src="@/assets/img/login/ic_extrusion@2x.png" alt="" />
        </div>
      </div>
      <div
        class="login_btn"
        style="margin-top: 14px"
        @click="loginBtn(3)"
        v-if="appType"
      >
        <img src="@/assets/img/login/apple@2x.png" alt="" />
        <span>{{
          $t('login_loginWith').replace('xx', $t('Login_apple'))
        }}</span>
        <div class="login_sign" v-show="loginWay === '3'">
          <span>{{ $t('login_recent') }}</span>
          <img src="@/assets/img/login/ic_extrusion@2x.png" alt="" />
        </div>
      </div> -->

      <div class="el_checkbox">
        <van-popover v-model="showPopover">
          <div class="popover_div">
            {{ $t('toast_agreeTermUsePP') }}
          </div>
          <template #reference>
            <img
              :src="
                checked
                  ? require('@/assets/img/login/login_ic_check_selected.svg')
                  : require('@/assets/img/login/login_ic_check_unselected.svg')
              "
              alt=""
              style="width: 14px; height: 14px"
              @click.prevent="
                checked = !checked
                showPopover = false
              "
            />
          </template>
        </van-popover>
        <span
          @click.prevent="
            checked = !checked
            showPopover = false
          "
        >
          {{ $t('login_agreeTo') }}&nbsp;
          <span class="el_checkbox_span" @click.stop="jumpTerm">
            {{ $t('login_termOfUse1') }} </span
          >&nbsp;{{ '&' }}&nbsp;
          <span class="el_checkbox_span" @click.stop="jumpPrivacy">
            {{ $t('loginPrivacyPolice1') }}
          </span>
        </span>
      </div>
    </div>

    <country-code
      :value="pageType == 2"
      @select="selectCode"
      @input="pageType = 3"
    ></country-code>

    <div class="container_page" v-if="pageType == 3" style="margin: 0">
      <div class="login_top">
        {{
          $t('login_loginWith').replace(
            'xx',
            ruleForm.loginType == 0 ? $t('Login_phone') : $t('login_email')
          )
        }}
      </div>
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-position="top"
        class="el_form"
      >
        <el-form-item
          prop="phone"
          class="el_form_phone"
          v-show="ruleForm.loginType == 0"
        >
          <div @click="pageType = 2" class="el_dropdown" id="el_dropdown">
            <span>
              +{{ ruleForm.code
              }}<i
                class="el-icon-arrow-down el-icon--right"
                style="margin-left: 10px"
              ></i>
            </span>
          </div>
          <el-input
            v-model="ruleForm.phone"
            type="tel"
            maxlength="15"
            :placeholder="$t('toast_requiredPhone')"
            :style="dropdownStyle"login_btn
            clearable
            @input="ruleForm.phone = formateNumber($event)"
          >
          </el-input>
        </el-form-item>
        <el-form-item prop="email" v-show="ruleForm.loginType == 6">
          <el-input
            v-model="ruleForm.email"
            type="email"
            maxlength="320"
            :placeholder="$t('toast_requiredEmail')"
            clearable
          >
          </el-input>
        </el-form-item>
        <el-form-item
          prop="phoneCode"
          class="el_form_code"
          v-show="ruleForm.loginType == 0"
        >
          <div
            class="code_div"
            id="code_div"
            @click.stop="phoneKey ? '' : handleSendPhone()"
            :style="
              phoneKey
                ? ' background: var(--primary-color-disable) !important; cursor: not-Allowed;'
                : ''
            "
          >
            {{ phoneText }}{{ phoneKey ? 's' : '' }}
          </div>
          <el-input
            v-model="ruleForm.phoneCode"
            maxlength="6"
            type="tel"
            :placeholder="$t('login_verificationCode')"
            :style="codeStyle"
            @input="ruleForm.phoneCode = formateNumber($event)"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item
          prop="emailCode"
          class="el_form_code"
          v-show="ruleForm.loginType == 6"
        >
          <div
            class="code_div"
            id="code_div"
            @click.stop="emailKey ? '' : handleSendEmail()"
            :style="
              emailKey
                ? ' background: var(--primary-color-disable) !important; cursor: not-Allowed;'
                : ''
            "
          >
            {{ emailText }}{{ emailKey ? 's' : '' }}
          </div>
          <el-input
            v-model="ruleForm.emailCode"
            maxlength="4"
            type="tel"
            :placeholder="$t('login_verificationCode')"
            :style="codeStyle"
            @input="ruleForm.emailCode = formateNumber($event)"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <div @click.prevent="submitForm" class="el_button">
            {{ $t('login_login') }}
          </div>
        </el-form-item>
      </el-form>
    </div>

    <!-- 语言切换 -->
    <van-dialog v-model="isShowLangDialog" :showConfirmButton="false">
      <div class="title">{{ $t('set_selectLanguage') }}</div>
      <div class="langBox">
        <div
          class="item"
          v-for="item in langList"
          @click="lang = item"
          :key="item.key"
        >
          <span>{{ $t(item.label) }}</span>
          <img
            v-if="item.key == lang.key"
            :src="require('@/assets/img/user/profile_ic_selected.svg')"
          />
        </div>
      </div>
      <div class="btns">
        <div class="btn flex_center" @click="cancelLang">
          {{ $t('profile_cancel') }}
        </div>
        <div class="btn flex_center" @click="saveLang">
          {{ $t('home_confirm') }}
        </div>
      </div>
    </van-dialog>
  </div>
</template>

<script>
import phoneCodes from '@/assets/js/phone-codes.json'
import $api from '@/assets/js/api/login'
import share from '@/mixins/share'
export default {
  mixins: [share],
  data () {
    var validateCode = (rule, value, callback) => {
      const codeReg = /^[0-9]{4}$/
      if (!value) {
        return callback(new Error(this.$t('toast_requiredCode')))
      }
      setTimeout(() => {
        if (codeReg.test(value)) {
          callback()
        } else {
          callback(new Error(this.$t('toast_validCode')))
        }
      }, 100)
    }
    const validatePhone = (rule, value, callback) => {
      const phoneReg = /^[0-9]{8,15}$/
      if (!value) {
        return callback(new Error(this.$t('toast_requiredPhone')))
      }
      setTimeout(() => {
        if (phoneReg.test(value)) {
          callback()
        } else {
          callback(new Error(this.$t('toast_validPhone')))
        }
      }, 100)
    }
    const validateEmail = (rule, value, callback) => {
      const emailReg = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
      if (!value) {
        return callback(new Error(this.$t('toast_requiredEmail')))
      }
      setTimeout(() => {
        if (emailReg.test(value)) {
          callback()
        } else {
          callback(new Error(this.$t('toast_validEmail')))
        }
      }, 100)
    }
    return {
      ruleForm: {
        code: '84',
        phoneCode: '',
        emailCode: '',
        phone: '',
        email: '',
        loginType: '', // 登录方式：0-手机号码登录 1-Facebook登录 2-Google登录 3-Apple登录 4-微信 5-支付宝 6-邮箱登录
        msgCode: '', // 短信验证码,loginType=0 时必传
        source: 2 // 登录来源,1-APP 2-H5 3-小程序
      },
      rules: {
        phoneCode: [{ validator: validateCode, trigger: 'blur' }],
        emailCode: [{ validator: validateCode, trigger: 'blur' }],
        phone: [{ validator: validatePhone, trigger: 'blur' }],
        email: [{ validator: validateEmail, trigger: 'blur' }]
      },
      pageType: 1, //页面类型 1：登录方式 2：获取区号  3: 协议及登录
      countryCode: '', //搜索区号
      countryList: phoneCodes, //区号数据
      dropdownWidth: '', //输入框距离下拉
      codeWidth: '', //输入框距离验证码
      // 电话验证码发送标识
      phoneKey: false,
      phoneText: '',
      phoneTime: 59,
      phoneInterval: null,
      // 邮箱验证码发送标识
      emailKey: false,
      emailText: '',
      emailTime: 59,
      emailInterval: null,
      userUrls: '', //用户协议
      privacyUrls: '', //隐私政策
      showPopup: false,
      loginWay: '',
      appType: '',
      loginParams: '',
      checked: false, //是否同意用户协议、隐私政策
      showPopover: false,
      isShowLangDialog: false,
      lang: { label: 'Việt Nam', key: 'VI', moment: 'vi' },
      langList: [
        { label: 'Việt Nam', key: 'VI', moment: 'vi' },
        { label: 'English', key: 'EN', moment: 'en' },
        { label: 'Chinese', key: 'ZH', moment: 'zh-cn' }
      ]
    }
  },
  computed: {
    dropdownStyle () {
      return {
        '--dropdownWidth': this.dropdownWidth
      }
    },
    codeStyle () {
      return {
        '--codeWidth': this.codeWidth
      }
    },
    listData () {
      let countryCode = this.countryCode
      if (countryCode) {
        //不区分大小写
        let reg = new RegExp(countryCode, 'ig')
        document.documentElement.scrollTop = 0
        //过滤匹配，有则返回当前，无则返回所有
        return this.countryList.filter(function (e) {
          //匹配所有字段
          return Object.keys(e).some(function (key) {
            return e[key].match(reg)
          })
        })
      }
      return this.countryList
    },
    getCurrentLang () {
      return this.langList.find(item => item.key == this.$i18n.locale)
    }
  },
  created () {
    this.pageType = localStorage.getItem('pageType') || '4'
    let phoneTime = localStorage.getItem('phoneTime') || ''
    let emailTime = localStorage.getItem('emailTime') || ''
    this.ruleForm.loginType = localStorage.getItem('loginType') || ''
    this.loginWay = String(localStorage.getItem('loginType')) || ''
    this.ruleForm.code = localStorage.getItem('code') || '84'
    this.ruleForm.phone = localStorage.getItem('phone') || ''
    this.ruleForm.email = localStorage.getItem('email') || ''
    this.checked = localStorage.getItem('checked') == 'true' || false
    if (phoneTime > 0) {
      this.phoneText = localStorage.getItem('phoneTime')
      this.phoneTime = localStorage.getItem('phoneTime')
      this.phoneKey = true
      this.startPhoneInterval()
    }
    if (emailTime > 0) {
      this.emailText = localStorage.getItem('emailTime')
      this.emailTime = localStorage.getItem('emailTime')
      this.emailKey = true
      this.startEmailInterval()
    }
    this.getLang()
    this.getConfigs()
    this.appType = this.isAppleDevice()
    localStorage.setItem('phoneOS', this.appType ? 'IOS' : 'Android')
  },
  mounted () {
    this.phoneText = this.$t('login_get')
    this.emailText = this.$t('login_get')
  },
  methods: {
    startedLogin () {
      this.pageType = 1
      localStorage.setItem('pageType', 1)
      document
        .querySelector('.container')
        .setAttribute('style', 'background-color:#ffffff !important;')
    },

    isAppleDevice () {
      return /Mac|ios|iPhone|iPad|iPod/.test(navigator.userAgent)
    },

    formateNumber (value) {
      if (!value) return
      return value.replace(/[^\d]/g, '')
    },

    //获取配置数据
    getConfigs () {
      $api.getConfigs(true).then(res => {
        if (res.code == 0) {
          localStorage.setItem('configs', JSON.stringify(res.data))
          res.data.forEach(item => {
            if (item.key == 'terms-of-use') {
              this.userUrls = item.value + `?lang=${this.$store.state.locale}`
            }
            if (item.key == 'privacy-policy') {
              this.privacyUrls =
                item.value + `?lang=${this.$store.state.locale}`
            }
          })
        }
      })
    },

    //获取宽度
    getWidth () {
      this.$nextTick(() => {
        let el_dropdown = document.getElementById('el_dropdown')
        this.dropdownWidth = el_dropdown.clientWidth + 44 + 'px'
        let code_div = document.getElementById('code_div')
        this.codeWidth = code_div.clientWidth + 24 + 'px'
      })
    },

    //选择区号
    selectCode (item) {
      this.countryCode = ''
      this.ruleForm.code = item
      this.$nextTick(() => {
        this.getWidth()
      })
      this.pageType = 3
      localStorage.setItem('code', item)
    },

    //手机/邮箱登录
    submitForm () {
      let props =
        this.ruleForm.loginType == 0
          ? ['phoneCode', 'phone']
          : ['emailCode', 'email']
      let resArr = []
      this.$refs.ruleForm.validateField(props, valid => {
        resArr.push(valid)
      })
      if (resArr.every(v => v === '')) {
        this.loginParams =
          this.ruleForm.loginType == 0
            ? {
                code: this.ruleForm.code,
                loginType: 0,
                msgCode: this.ruleForm.phoneCode,
                phone: this.ruleForm.phone,
                source: 2
              }
            : {
                loginType: 6,
                msgCode: this.ruleForm.emailCode,
                email: this.ruleForm.email,
                source: 2
              }
        this.loginApi()
      } else {
        return false
      }
    },

    //用户协议
    jumpTerm () {
      if (!this.userUrls) return
      localStorage.setItem(
        'webUrl',
        JSON.stringify({
          url: `${this.userUrls}?lang=${this.$store.state.locale}`,
          title: 'login_termOfUse'
        })
      )
      localStorage.setItem('checked', this.checked)
      this.$router.push({
        path: '/web-view'
      })
    },

    //隐私政策
    jumpPrivacy () {
      if (!this.privacyUrls) return
      localStorage.setItem(
        'webUrl',
        JSON.stringify({
          url: `${this.privacyUrls}?lang=${this.$store.state.locale}`,
          title: 'loginPrivacyPolice'
        })
      )
      localStorage.setItem('checked', this.checked)
      this.$router.push({
        path: '/web-view'
      })
    },

    //获取验证码
    getLoginCode () {
      let params =
        this.ruleForm.loginType == 0
          ? {
              code: this.ruleForm.code,
              phone: this.ruleForm.phone,
              scene: 1
            }
          : {
              email: this.ruleForm.email,
              scene: 1
            }
      // console.log(params)
      $api.getLoginCode(params).then(res => {
        if (res.code == 0) {
          this.global.toast(res.message)
          if (this.ruleForm.loginType == 0) {
            this.phoneText = this.phoneTime
            this.phoneKey = true
            this.startPhoneInterval()
          } else {
            this.emailText = this.phoneTime
            this.emailKey = true
            this.startEmailInterval()
          }
        } else {
          this.global.toast(res.message)
        }
      })
    },

    // 处理发送验证码
    handleSendPhone () {
      // 判断是否可以发送（时间限制）
      if (this.phoneKey) return
      // 发送验证码
      this.timeCalcPhone()
    },

    // 时间计算
    timeCalcPhone () {
      // 计时避免重复发送
      this.$refs.ruleForm.validateField('phone', valid => {
        if (!valid) {
          this.getLoginCode()
        }
      })
    },

    //手机验证定时器
    startPhoneInterval () {
      this.phoneInterval = window.setInterval(() => {
        this.phoneTime--
        this.phoneText = this.phoneTime
        localStorage.setItem('phoneTime', this.phoneTime)
        if (this.phoneTime === 0) {
          this.phoneTime = this.$options.data.call(this).phoneTime
          this.phoneText = this.$t('login_get')
          this.phoneKey = false
          window.clearInterval(this.phoneInterval)
          this.phoneInterval = null
          localStorage.removeItem('phoneTime')
        }
      }, 1000)
    },

    // 处理发送验证码
    handleSendEmail () {
      // 判断是否可以发送（时间限制）
      if (this.emailKey) return
      // 发送验证码
      this.timeCalcEmail()
    },

    // 时间计算
    timeCalcEmail () {
      // 计时避免重复发送
      this.$refs.ruleForm.validateField('email', valid => {
        if (!valid) {
          this.getLoginCode()
        }
      })
    },

    //邮箱验证定时器
    startEmailInterval () {
      this.emailInterval = window.setInterval(() => {
        this.emailTime--
        this.emailText = this.emailTime
        localStorage.setItem('emailTime', this.emailTime)
        if (this.emailTime === 0) {
          this.emailTime = this.$options.data.call(this).emailTime
          this.emailText = this.$t('login_get')
          this.emailKey = false
          window.clearInterval(this.emailInterval)
          this.emailInterval = null
          localStorage.removeItem('emailTime')
        }
      }, 1000)
    },

    // 选择登录方式
    loginBtn (index) {
      if (this.checked == false) {
        this.showPopover = true
        setTimeout(() => {
          this.showPopover = false
        }, 3000)
        return
      }
      this.ruleForm.loginType = index
      if (index === 0) {
        this.pageType = 3
        this.ruleForm.phone = this.ruleForm.phone
          ? this.ruleForm.phone
          : localStorage.getItem('phone') || ''
        this.getWidth()
      }

      if (index == 2) {
        this.googleSignIn()
      }

      if (index == 3) {
        this.appleSignIn()
      }
    },

    // 登录api
    loginApi () {
      $api.loginAction(this.loginParams).then(res => {
        if (res.code == 0) {
          localStorage.setItem('token', res.data.token)
          localStorage.setItem('platformId', res.data.platformId || 1)
          $api
            .switchPlatform({ platformId: res.data.platformId || 1 })
            .then(res => {
              if (res.code == 0) {
                let uid = res.data.uid
                $api.getUsersMsg().then(res => {
                  if (res.code == 0) {
                    this.global.toast(res.message)
                    res.data.uid = uid
                    localStorage.setItem('userInfo', JSON.stringify(res.data))
                    this.getConfigs()
                    window.clearInterval(this.phoneInterval)
                    localStorage.removeItem('phoneTime')
                    window.clearInterval(this.emailInterval)
                    localStorage.removeItem('emailTime')
                    localStorage.removeItem('checked')
                    localStorage.setItem('phone', this.ruleForm.phone)
                    localStorage.setItem('email', this.ruleForm.email)
                    localStorage.setItem('loginType', this.ruleForm.loginType)
                    localStorage.setItem('pay_result', '')
                    localStorage.setItem('device_info', '')
                    localStorage.setItem('webUrl', '')
                    this.$router.push('/home')
                    this.showPopup = false
                  } else {
                    this.global.toast(res.message)
                  }
                })
              } else {
                this.global.toast(res.message)
              }
            })
        } else {
          this.global.toast(res.message)
        }
      })
    },

    // 苹果登录
    async appleSignIn () {
      // 调用苹果登录接口
      await window.AppleID.auth.init({
        clientId: 'co.com.joltzly20250210', // 替换为你的 Client ID
        scope: 'name email', // 请求的权限
        redirectURI: process.env.H5_URL, // 替换为你的回调地址
        usePopup: true // 使用弹窗模式
      })

      await window.AppleID.auth.signIn().then(
        response => {
          // 处理登录成功的逻辑
          const appleUserData = this.getJWTToken(
            response.authorization.id_token
          )
          const email = appleUserData.email ? appleUserData.email : ''
          this.loginParams = {
            loginMsg: appleUserData.sub,
            loginType: 3,
            email: email,
            source: 2
          }
          this.loginApi()
        },
        error => {
          console.error('Apple Login Error:', error)
        }
      )
    },

    //解析JWT
    getJWTToken (token) {
      var base64Url = token.split('.')[1]
      var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/')
      var jsonPayload = decodeURIComponent(
        atob(base64)
          .split('')
          .map(function (c) {
            return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
          })
          .join('')
      )
      return JSON.parse(jsonPayload)
    },

    // 谷歌登录
    async googleSignIn () {
      const client = await google.accounts.oauth2.initTokenClient({
        client_id:
          '461172452242-ggohvbsg2j3dd95n4bm3it0t2bg6elrh.apps.googleusercontent.com', // 替换为你的 Client ID
        scope: 'email profile', // 请求的权限
        redirect_uri: process.env.H5_URL,
        ux_mode: 'popup',
        callback: response => this.getGoogleId(response)
      })

      client.requestAccessToken() // 请求访问令牌
    },

    // 使用Access Token获取用户数据
    getGoogleId (response) {
      // console.log('Google Login Success:', response)
      const accessToken = response.access_token
      this.$store.commit('startLoading')
      // 示例：通过 API 获取用户信息
      fetch('https://www.googleapis.com/oauth2/v2/userinfo', {
        headers: {
          Authorization: `Bearer ${accessToken}`
        }
      })
        .then(res => res.json())
        .then(userInfo => {
          const email = userInfo.email ? userInfo.email : ''
          this.loginParams = {
            loginMsg: userInfo.id,
            loginType: 2,
            email: email,
            source: 2
          }
          this.$store.commit('endLoading')
          this.loginApi()
        })
        .catch(err => {
          console.error('Google Login Error:', err)
        })
    },

    //切换语言
    showLang () {
      this.lang = this.getCurrentLang
      this.isShowLangDialog = true
    },
    cancelLang () {
      this.isShowLangDialog = false
    },
    saveLang () {
      const lang = this.lang
      this.$i18n.locale = lang.key
      this.$moment.locale(lang.moment)
      localStorage.setItem('lang', lang.key)
      localStorage.setItem('moment_lang', lang.moment)
      this.$store.commit('SET_LANG', lang.key)
      this.isShowLangDialog = false
      this.phoneText = this.$t('login_get')
      this.emailText = this.$t('login_get')
    }
  }
}
</script>
<style>
.van-divider--content-center::before,
.van-divider--content-left::before,
.van-divider--content-right::before {
  margin-right: 10px !important;
}
.van-divider--content-center::after,
.van-divider--content-left::after,
.van-divider--content-right::after {
  margin-left: 10px !important;
}
</style>
<style scoped lang="scss">
.container {
  background: #ffffff;
}
.Low_battery {
  width: calc(100% - 40px);
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  color: #ffffff;
  line-height: 24px;
  margin: 86px 0 80px 20px;
}
.get_started {
  width: calc(100% - 56px);
  margin-left: 20px;
  height: 98px;
  position: fixed;
  bottom: 0;
  background: transparent;
  border: none;
  .get_started_div {
    height: 52px;
    box-sizing: border-box;
    background: var(--text-color);
    border-radius: 14px;
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    color: #ffffff;
    line-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.login_top {
  padding: 16px 0;
  font-size: 28px;
  font-weight: Bold;
  text-align: center;
  color: var(--text-color);
  line-height: 34px;
}
.login_lang {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0 84px 0;
  .login_lang_div {
    height: 36px;
    background: rgb(0,0,0,0.3);
    border-radius: 17px;
    position: relative;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    span {
      padding: 0 56px 0 20px;
      font-size: 14px;
      font-weight: 500;
      text-align: center;
      color: #ffffff;
      line-height: 16px;
    }
    img {
      width: 36px;
      height: 36px;
      position: absolute;
      right: 0;
    }
  }
}
.login_btn {
  width: 100%;
  height: 52px;
  background: #f7f7f9;
  border-radius: 5px;
  display: flex;
  align-items: center;
  position: relative;
  img {
    width: 32px;
    height: 32px;
    margin-left: 56px;
  }
  span {
    font-size: 17px;
    font-weight: 400;
    text-align: left;
    color: #39404d;
    line-height: 24px;
    letter-spacing: 0.32px;
    margin: 0 16px;
  }
  .login_sign {
    position: absolute;
    height: 20px;
    background: #000000;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    right: 24px;
    top: -10px;
    span {
      font-size: 12px;
      font-weight: 400;
      text-align: center;
      color: #e7ff55;
      line-height: 14px;
      letter-spacing: 0.23px;
    }
    img {
      width: 4px;
      height: 4px;
      position: absolute;
      top: 20px;
      left: 16px;
      margin-left: 0;
    }
  }
}

.el_form {
  width: 100%;
  margin-top: 28px;

  ::v-deep .el-form-item {
    margin-bottom: 20px;
  }

  ::v-deep .el-input__inner {
    height: 52px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    color: #39404d;
    line-height: 16px;
    background: #f0f0f2;
    border-radius: 14px;
    padding-left: 28px;
  }

  ::v-deep .el-input__inner::placeholder {
    color: #888888;
  }

  ::v-deep .el-form-item__error {
    left: 8px;
  }

  ::v-deep .is-error {
    margin-bottom: 26px;
  }

  .el_form_phone {
    .el_dropdown {
      position: absolute;
      z-index: 6;
      left: 28px;
      line-height: 54px;
      color: #39404d;
      font-size: 14px;
      font-weight: 600;
    }
    ::v-deep .el-input__inner {
      padding-left: var(--dropdownWidth) !important;
    }
  }

  .el_form_code {
    .code_div {
      position: absolute;
      z-index: 6;
      right: 8px;
      top: 8px;
      height: 36px;
      color: #39404d;
      font-size: 12px;
      font-weight: 500;
      background: var(--btn-color);
      border-radius: 6px;
      padding: 0 8px;
      text-align: center;
      color: #ffffff;
      line-height: 36px;
      min-width: 88px;
      transition: all 0.2s ease-in-out;
    }
    .code_div:active {
      background: var(--primary-color-light);
    }
    ::v-deep .el-input__inner {
      padding-right: var(--codeWidth) !important;
    }
    ::v-deep .el-input__suffix {
      right: var(--codeWidth) !important;
    }
  }

  .el_button {
    width: 100%;
    height: 52px;
    background: var(--btn-color);
    transition: all 0.2s ease-in-out;
    border: none;
    // border: 1px solid transparent !important;
    box-sizing: border-box;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 500;
    line-height: 20px;
    text-align: center;
    color: #ffffff;
    white-space: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 68px;
  }
  .el_button:active {
    background: var(--primary-color-light) !important;
  }
}

.langBox {
  background-color: var(--card-color);

  .item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 52px;
    padding: 0 var(--gap);
    border-bottom: #eeeef5 1px solid;
    &:nth-last-child(1) {
      border: none;
    }
    span {
      font-size: 14px;
      color: #383838;
    }
    img {
      width: 20px;
      height: 20px;
    }
  }
}
.el_checkbox {
  margin-top: 20px;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  color: #39404d;
  line-height: 24px;
  display: flex;
  align-items: flex-start;
  ::v-deep .van-popover__wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin: 5px 6px 0 0;
  }
  .el_checkbox_span {
    text-decoration: underline;
    color: var(--text-color);
  }
}
</style>
<style>
.popover_div {
  padding: 10px 16px;
  background: #aaaaac;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  color: #ffffff;
  line-height: 14px;
}
.van-popover {
  max-width: calc(100% - 56px) !important;
  background: #aaaaac !important;
  border-radius: 8px;
  left: 28px !important;
}
.van-toast__text {
  margin-top: 0 !important;
}
.van-popover--light .van-popover__content {
  background: #aaaaac !important;
  border-radius: 8px;
}
.van-popover__arrow {
  left: 8px !important;
}
.van-popover--light .van-popover__arrow {
  color: #aaaaac !important;
  transform: translate(-16%, -95%) !important;
}
</style>
